import React, { Component } from 'react'
import Button from './Button'
import Num from './Num'

export default class Counter extends Component {

  constructor() {
    super();
    this.state = {
      num: 100
    }
  }

  handleChange(n) {
    console.log(n)
    this.setState({
      num:this.state.num +=n
    },()=>{
      console.log(this.state.num)
    })
  }

  render() {
    return (
      <div>
        <Button type="decrement" change={(n) => this.handleChange(n)}>-</Button>
        <Num init={this.state.num}></Num>
        <Button change={(n) => this.handleChange(n)} type="increment">+</Button>

      </div>
    )
  }
}
